package com.RPC.client.action;

import com.RPC.server.ask.UserReq;
import com.RPC.server.ask.UserRes;
import com.google.common.util.concurrent.ListenableFuture;
import com.yaxon.vndp.rpc.Message;
import com.yaxon.vndp.rpc.RpcClient;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.concurrent.ExecutionException;

/**
 * Author: <黄书根>
 * Time: 2017-08-04 15:00
 * Copyright (C) 2017 Xiamen Yaxon Networks CO.,LTD.
 */
@ParentPackage("struts-default")
@Namespace("/Rpc")
@Action(value="UserAction")
public class UserAction {
    @Autowired
    @Qualifier("dsRpcClient")
    protected RpcClient dsRpcClient;
    private UserReq userReq;
    public void getUser(){
        userReq=new UserReq();
        ListenableFuture<Message> future= dsRpcClient.invoke(userReq);
        try {
            UserRes red=(UserRes)future.get();
        }  catch (Exception e) {
            e.printStackTrace();
        }

    }
}
